home *** CD-ROM | disk | FTP | other *** search
- //: C14:Hide.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Name hiding during inheritance
-
- class Homer {
- public:
- int doh(int) const { return 1; }
- char doh(char) const { return 'd';}
- float doh(float) const { return 1.0; }
- };
-
- class Bart : public Homer {
- public:
- class Milhouse {};
- void doh(Milhouse) const {}
- };
-
- int main() {
- Bart b;
- //! b.doh(1); // Error
- //! b.doh('x'); // Error
- //! b.doh(1.0); // Error
- } ///:~
-